﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using Microsoft.MediaCenter.UI;
using System.IO;
using System.Diagnostics;
using System.Windows.Forms;



namespace RadioStream.Code.Utils
{
    class FileUtil
    {
        static public Microsoft.MediaCenter.UI.Image Res2Image(String RessourceURI)
        {
            Microsoft.MediaCenter.UI.Image retImage = null;
            Assembly myAssembly = Assembly.GetExecutingAssembly();
            //string[] names = myAssembly.GetManifestResourceNames();
            //foreach (string name in names)
            //{
            //    Debug.WriteLine(name);
            //}
            System.IO.Stream file = myAssembly.GetManifestResourceStream(RessourceURI);
            ImageRequirements ImgReq = new ImageRequirements(false);
            retImage = Image.FromStream(file, ImgReq);
            //file.Close();
            return retImage;
        }

        static public List<int> ReadFavourites(string fileURI)
        {
            List<int> FavList = new List<int>();

            try
            {
                StreamReader sr = new StreamReader(fileURI);
                string input = null;
                while ((input = sr.ReadLine()) != null)
                {
                    FavList.Add(Convert.ToInt32(input));
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }
            return FavList;
        }
    }
}
